<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <button onclick="send()">发送消息</button>

  <script src="socket.io.js"></script>
  <script>
    let socket = io('http://127.0.0.1:9000');

    function send(){
      socket.emit('kefu','我是客户端'+Date.now())
    }

    // socket.on()用于接收服务端发来的消息
    socket.on('serverkefu', data => {
      console.log(data);
    });

    


  </script>

</body>

</html>